<?php
/**
 * Created by PhpStorm.
 * User: 戎大富
 * Date: 2020/9/15
 * Time: 16:50
 */
namespace app\admin\controller;
use think\Db;
use think\Request;
class Reckon extends Base {
    public function index(){
        if(Request::instance()->isPost()){
            $go_address = input('param.go_address');
            $to_address = input('param.to_address');
            $cc = input('param.cc');
            $latlog = addresstolatlag($go_address);//获取经纬度
            $latlog1 = addresstolatlag($to_address);//获取经纬度
            $log1 = round($latlog['log'],5);
            $lat1 = round($latlog['lat'],5);
            $log2 = round($latlog1['log'],5);
            $lat2 = round($latlog1['lat'],5);
            $origin = $log1.','.$lat1;
            $destination = $log2.','.$lat2;
            $result = aaa($origin,$destination);
            $res = '';
            if($cc=='4.2米及以下车型'){
                $res = 3*$result;
            }elseif ($cc=='6.8米车型'){
                $res = 6*$result;
            }elseif($cc=='9.6米车型'){
                $res = 7*$result;
            }elseif ($cc=='13米车型'){
                $res = 9*$result;
            }elseif ($cc=='17.5米车型'){
                $res = 11*$result;
            }
            return json(['status'=>200,'msg'=>round($res,2)]);
        }
        $where['is_del'] = 1;
        $where['is_status'] = 1;
        $list = Db::table('up_car_cclb')->where($where)->where('cclb_id','in',array(1,2,3,4,5))->select();
        $this->assign('list',$list);
        return $this->fetch();
    }
}